package banking;

import banking.domain.OverdraftException;

public class CheckingAccount extends Account {
    private double overdraftProtection;

    public CheckingAccount(double init_balance) {
        super(init_balance);
        this.overdraftProtection = 0;
    }

    public CheckingAccount(double init_balance, double overdraftProtection) {
        super(init_balance);
        this.overdraftProtection = overdraftProtection;
    }

    @Override
    public void withdraw(double balance) throws OverdraftException {
        if (balance < this.balance + this.overdraftProtection) {
            this.balance -= balance;
        }else{
            throw new OverdraftException("Insufficient funds for overdraft protection", this.balance + this.overdraftProtection);
        }
    }

}
